<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<script type="text/javascript">
	function checkForm() {
		var title = document.getElementById("title").value;
		var content = CKEDITOR.instances.content.getData();
		var typeId = document.getElementById("categoryId").value;
		if (title == null || title == "") {
			document.getElementById("error").innerHTML = "标题不能为空！";
			return false;
		}
		if (content == null || content == "") {
			document.getElementById("error").innerHTML = "内容不能为空！";
			return false;
		}
		if (categoryId == null || categoryId == "") {
			document.getElementById("error").innerHTML = "请选择类别！";
			return false;
		}
		return true;
	}
</script>
<div class="data_list">
	<div class="data_list_title">
		<c:choose>
			<c:when test="${article.id!=null }">
				<img
					src="${pageContext.request.contextPath}/image/icon/diary_type_edit_icon.png" />
				<span>修改博文</span>
			</c:when>
			<c:otherwise>
				<img
					src="${pageContext.request.contextPath}/image/icon/diary_add_icon.png" />
				<span>写博文</span>
			</c:otherwise>
		</c:choose>
	</div>
	<form action="articleManage?action=save" method="post"
		onsubmit="return checkForm()">
		<div>
			<div class="article-title">
				<input type="text" id="title" name="title" value="${article.title }"
					class="input-xlarge"
					style="margin-top: 5px; margin-botton: 5px; height: 30px; width: 50%;"
					placeholder="标题..." />
			</div>
			<h4>博文内容</h4>
			<div>
				<textarea class="ckeditor" id="content" name="content">${article.content }</textarea>
			</div>
			<h4>博文摘要</h4>
			<div>
				<textarea class="ckeditor" id="remark" name="remark">${article.remark }</textarea>
			</div>

			<div class="article_type">
				<select id="categoryId" name="categoryId">
					<option value="">请选择类别...</option>
					<c:forEach var="category" items="${categories}">
						<option value="${category.id }"
							${category.id==article.category.id?'selected':'' }>${category.name}</option>
					</c:forEach>
				</select> <select id="picture" name="picture">
					<option value="">请选择图片...</option>
					<c:forEach var="picture" items="${pictures}">
						<option value="${picture}"
							${article.picture==picture?'selected':'' }>${picture}</option>
					</c:forEach>
				</select>
			</div>
			<div>
				<input type="hidden" id="articleId" name="articleId"
					value="${article.id }" /> <input type="submit"
					class="btn btn-primary" value="保存" />
				<button class="btn btn-primary" type="button"
					onclick="javascript:history.back()">返回</button>
				<font id="error" color="red">${error}</font>
			</div>
		</div>
	</form>
</div>